package com.ch.home.service.serviceImpl.userServiceImpl;

import com.ch.home.bean.Feedback;
import com.ch.home.mapper.userMessageMapper.FeedbackMapper;
import com.ch.home.service.serviceInterface.user.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;

/**
 * Created by CHEN on 2019/8/24.
 */
@Service
public class FeedbackServiceImpl implements  FeedbackService{


    @Autowired
    FeedbackMapper feedbackMapper;


    @Override
    public HashMap addFeedback(Feedback feedback){

        HashMap<Object,Object> result = new HashMap();
        int re =feedbackMapper.addFeedback(feedback);

        if (re == 1) {
            result.put("message", "success");
        } else {
            result.put("message", "fail");
        }

        return result;
    }
    @Override
    public HashMap getFeedback(Integer userId, Date earlierTime, Date laterTime){
        HashMap<Object,Object> result = new HashMap();

        LinkedList<Feedback> feedbacks = feedbackMapper.getFeedback(userId, earlierTime, laterTime);

        if ( feedbacks.size()>0) {
            result.put("message", "success");
        } else {
            result.put("message", "fail");
        }

        result.put("value",feedbacks);
        return result;
    }

}
